<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var foo = function (x, y) {
            return x - y;
        }

        function foo(x, y) {
            return x + y;
        }
        var num = foo(1, 2);
        console.log(num); //-1
        //  1. 变量声明、函数声明都会被提升到作用域顶处；
        //  2. 当出现相同名称时，优先级为：变量声明(foo#1) < 函数声明(foo#2) < 变量赋值(foo#3)
    </script>
</body>

</html>